class TrackerWebHandler:
    def __init__(self, tracker):
        self.tracker = tracker                    
    def stop(self):
        from common import web_server        
        web_server.stop()    
    def reset(self):
        self.tracker.reset()    
    def run_sql(self, query):
        self.tracker.run_sql(query)
    def web_publish(self):
        tracker = self.tracker
        m = {}
        m['rpc_port'] = tracker.rpc_port        
        m['peers'] = tracker.peers.values()        
        m['num_peers'] = len(tracker.peers)
        if tracker.sql_results is not None:
            m['sql_results'] = tracker.sql_results
            tracker.sql_results = None 
        return m